package com.sky.mapper.user;

import com.sky.dto.ShoppingCartDTO;
import com.sky.pojo.AddressBook;
import com.sky.pojo.Dish;
import com.sky.pojo.Setmeal;
import com.sky.pojo.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    int ShoppingCartadd(ShoppingCart shoppingCar);
    /**
     * 根据userId setmealId dishId查询购买的所有商品
     */
    ShoppingCart selectShoppingCart(@Param("userId") Long userId ,@Param("dto") ShoppingCartDTO dto);
    @Update("update shopping_cart set number=number+1 where dish_id=#{dishId}")
    int updateDishNumber(Long dishId);
    @Update("update shopping_cart set number=number+1 where setmeal_id=#{setmealId}")
    int updatesetmealNumber(Long setmealId);
    @Select("select * from shopping_cart")
    List<ShoppingCart> list();
    @Delete("delete from shopping_cart")
    void deleteShoppingCart();

    /**
     * 更具 userid查询出来菜品和套餐的制作时间
     * @param userId
     * @return
     */
    List<Integer> getByUserIdDishId(Integer userId);

    List<Integer> getByUserIdsetmeal(Integer userId);
    @Select("select * from address_book where id=#{addressBookId}")
    AddressBook selectAddressAll(Integer addressBookId);

    /**
     * 根据UserId 查询
     */
    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> getByUserId(Integer userId);
    //根据userid 删除
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteByUserId(Long userId);
}
